// ==UserScript==
// @id             xiami auto sign
// @name           虾米自动签到机
// @version        1.4
// @namespace
// @author         luomo
// @description
// @include        http://www.xiami.com/*
// @require        http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
// @updateURL      http://luomo-git.googlecode.com/git/xiamiautosign.user.js
// @run-at         document-end
// ==/UserScript==


var _Date = new Date();
var _now = _Date.toDateString();
var _lastSignTime = GM_getValue('lastSignTime', 'undefined');
if (_now != _lastSignTime) {
	$.get("http://www.xiami.com/", function (data) {
		var ret = GM_xmlhttpRequest({
				method : "POST",
				url : "http://www.xiami.com/task/signin",
				onload : function (res) {
					if (!isNaN(res.responseText)) {
						GM_setValue('lastSignTime', _now);
					}
				},
				headers : {
					'Referer' : 'http://www.xiami.com/',
					'Host' : 'www.xiami.com',
					'Cookie' : document.cookie
				}
			});
	})
}
